package com.meilai.project.mapper.business.contract;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.meilai.project.entity.business.contract.ProxyMediaDetail;
import com.meilai.project.entity.business.contract.ProxyMediaDetailExt;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author xchen
 * @since 2022-04-13
 */
public interface ProxyMediaDetailMapper extends BaseMapper<ProxyMediaDetail> {

    @Delete("delete from proxy_media_detail where type = #{type} and biz_id = #{bizId}")
    void cleanByBizId(@Param("type") int type, @Param("bizId") Long id);

    @Select("select pmd.*, vmtip.name as media_type_name from proxy_media_detail pmd " +
            "join v_media_type_include_proxy vmtip on " +
            " pmd.media_type_category = vmtip.type and pmd.media_type_id = vmtip.id " +
            "where pmd.type = #{type} and biz_id = #{bizId}")
    List<ProxyMediaDetailExt> queryByBizId(@Param("type") int type, @Param("bizId") Long id);

    List<ProxyMediaDetailExt> queryByBizIdList(@Param("type") int type, @Param("idList") List<Long> idList);
}
